--- title: Title keywords: fastai sidebar: home_sidebar nb_path: "EDA_NYC_taxi.ipynb" ---
import plotly.graph_objects as go
import plotly.express as px
import pandas as pd
import numpy as np
df = pd.read_csv("C:\\Users\\raksh\\Desktop\\PR\\nyc_taxi.csv")
fig = px.line(df, x = 'timestamp', y = 'value')
fig.show()
fig = go.Figure([go.Scatter(x=df['timestamp'], y=df['value'])])
fig.show()
fig = px.bar(df, x='timestamp', y="value")
fig.show()
fig = px.histogram(df, x="timestamp", y="value", histfunc="avg", title="Histogram on Date Axes")
fig.update_traces(xbins_size="M1")
fig.update_xaxes(showgrid=True, ticklabelmode="period", dtick="M1", tickformat="%b\n%Y")
fig.update_layout(bargap=0.1)
fig.add_trace(go.Scatter(mode="markers", x=df["timestamp"], y=df["value"], name="daily"))
fig.show()
fig = px.line(df, x='timestamp', y='value', range_x=['2014-11-01','2015-01-31'])
fig.show()
fig.update_xaxes(rangeslider_visible=True)
fig.show()
# plot with range slider and range selector
fig = px.line(df, x='timestamp', y='value', title='Time Series with Range Slider and Selectors')
fig.update_xaxes(
rangeslider_visible=True,
rangeselector=dict(
buttons=list([
dict(count=1, label="1m", step="month", stepmode="backward"),
dict(count=6, label="6m", step="month", stepmode="backward"),
dict(count=1, label="YTD", step="year", stepmode="todate"),
dict(count=1, label="1y", step="year", stepmode="backward"),
dict(step="all")
])
)
)
fig.show()
fig = go.Figure(go.Scatter(
x = df['timestamp'],
y = df['value']
))
fig.update_xaxes(
rangeslider_visible=True,
tickformatstops = [
dict(dtickrange=[None, 1000], value="%H:%M:%S.%L ms"),
dict(dtickrange=[1000, 60000], value="%H:%M:%S s"),
dict(dtickrange=[60000, 3600000], value="%H:%M m"),
dict(dtickrange=[3600000, 86400000], value="%H:%M h"),
dict(dtickrange=[86400000, 604800000], value="%e. %b d"),
dict(dtickrange=[604800000, "M1"], value="%e. %b w"),
dict(dtickrange=["M1", "M12"], value="%b '%y M"),
dict(dtickrange=["M12", None], value="%Y Y")
]
)
fig.show()